package com.easy.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.easy.common.bean.SysRole;
import com.easy.common.bean.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<SysUser> {

    @Delete("delete from sys_user_role where user_id=#{userid}")
    int deleteUserRoleByUserID(@Param("userid") Integer userid);

    @Insert("insert into sys_user_role value (#{userid},#{roleid})")
    int insertUserRole(@Param("userid")Integer userid, @Param("roleid")Integer roleid);

    @Select("select a.* from sys_role a left join sys_user_role b on a.id=b.role_id where b.user_id=#{userid}")
    List<SysRole> getUserRoles(@Param("userid")Integer userid);
    @Select("select * from sys_user where username=#{username}")
    SysUser getOneByUsername(@Param("username")String username);
}
